<template>
  <div id="activeTopSearch">
    <div class="search-box">
      <el-form
        ref="ruleForm"
        :inline="true"
        :model="formInline"
        class="demo-form-inline"
      >
        <el-form-item label="大鹏号：" prop="dpAccount">
          <el-input
            v-model="formInline.dpAccount"
            placeholder="请输入大鹏号"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="日期" prop="createTime">
          <el-date-picker
            :clearable="false"
            class="data-input"
            v-model="formInline.statisticDate"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
            :picker-options="pickerTopDataDay"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item class="s-btn">
          <el-button type="success" icon="el-icon-search" @click="toSearch()">
            查询
          </el-button>
          <el-button type="success" plain @click="reset">
            重置
          </el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { getDay } from '@utils/yesterday.js'
export default {
  props: {
    formInline: {
      type: Object,
      default: function() {
        return {
          dpAccount: '',
          statisticDate: ''
        }
      }
    }
  },
  data() {
    return {
      pickerTopDataDay: {
        disabledDate(time) {
          //昨天之后不可选
          const yesterday = new Date() - 3600 * 1000 * 24 * 1
          return time.getTime() > yesterday
        }
      }
    }
  },
  mounted() {},
  methods: {
    /* 搜索 */
    toSearch() {
      this.$emit('toSearch')
    },
    /* 重置 */
    reset() {
      this.$refs['ruleForm'].resetFields()
      this.setDefaultValue()
    },
    setDefaultValue() {
      this.formInline.dpAccount = ''
      this.formInline.statisticDate = getDay(-1, '-')
    }
  }
}
</script>

<style lang="less" scoped>
.search-box :deep(.el-input__inner) {
  padding: 0 30px;
}
</style>
